local zhenyi = fk.CreateSkill{
    name = "ym2__zhenyi",
    tags = {Skill.Compulsory}
}
Fk:loadTranslationTable{
    ["ym2__zhenyi"] = "真仪",
    [":ym2__zhenyi"] = "锁定技，你达成连招后，若连招牌花色均相同，你使用同色牌无距离限制且不可响应；否则你发动“点化”卜算牌数+1。"..
    "<br/><font color = 'grey'><small>（注：由于连招技的相关机制尚不完善，请不要汇报达成某些连招技后获得延时效果不正确的bug）</font>",
    ["@[ym2__zhenyi]"] = "真仪",

    ["$ym2__zhenyi1"] = "白鸥引醴泉之水，青鹿衔牡野之苹，冯虚御风，可称仙仪。",
    ["$ym2__zhenyi2"] = "朱雀献首阳之火，玄龟捧息洪之壤，涅槃造化，方成真我。",
}
Fk:addQmlMark{
    name = "ym2__zhenyi",
    how_to_show = function(name, value, p)
        if type(value) ~= "table" then return " " end
        if value.value == 0 then
            return table.concat(table.map(value.suits,function (element, index, array)
                return Fk:translate(element)
            end))
        else
            return tostring(value.value) .. " " .. table.concat(table.map(value.suits,function (element, index, array)
                return Fk:translate(element)
            end))
        end
    end,
    qml_path = "",
}
zhenyi:addEffect(fk.AfterCardUseDeclared, {
    priority = 0.000001,
    can_trigger = function (self, event, target, player, data)
        if target == player then
            local room = player.room
            local mark = player:getTableMark(zhenyi.name)
            for _, skill in ipairs(player.player_skills) do
                if skill:isPlayerSkill(player) and skill.visible and
                Fk:getDescription(skill.name, "zh_CN"):startsWith("连招技") and not table.contains({"ym2__falu"},skill.name) then
                    mark[skill.name] = mark[skill.name] or {}
                    table.insertTable(mark[skill.name],{data.card.suit})
                    if data.extra_data and data.extra_data.combo_skill and data.extra_data.combo_skill[skill.name] then
                        local suits = {}
                        for _, value in ipairs(mark[skill.name]) do
                            table.insertIfNeed(suits,value)
                        end
                        local mark2 = player:getMark("@[ym2__zhenyi]") == 0 and {value = 1,suits = {}} or player:getMark("@[ym2__zhenyi]")
                        if #suits == 1 then
                            table.insertIfNeed(mark2.suits,data.card:getSuitString(true))
                        else
                            mark2.value = mark2.value + 1
                        end
                        room:notifySkillInvoked(player,zhenyi.name,"special")
                        room:setPlayerMark(player,"@[ym2__zhenyi]",mark2)
                        mark[skill.name] = {}
                    elseif player:getMark("@"..skill.name) == 0 and player:getMark(skill.name) == 0 then
                        mark[skill.name] = {}
                    end
                end
            end
            room:setPlayerMark(player,zhenyi.name,mark)
            return false
        end
    end,
})
zhenyi:addEffect(fk.AfterCardsMove, {
    priority = 0.000001,
    can_trigger = function (self, event, target, player, data)
        if player:hasSkill("ym2__falu") then
            for _, move in ipairs(data) do
                if move.from == player then
                    if move.extra_data and move.extra_data.combo_skill and move.extra_data.combo_skill["ym2__falu"] then
                        for _, value in ipairs(move.extra_data.combo_skill["ym2__falu"]) do
                            local mark = player:getMark("@[ym2__zhenyi]") == 0 and {value = 1,suits = {}} or player:getMark("@[ym2__zhenyi]")
                            if value ~= "nosuit" then
                                table.insertIfNeed(mark.suits,"log_"..value)
                            else
                                mark.value = mark.value + 1
                            end
                            player.room:setPlayerMark(player,"@[ym2__zhenyi]",mark)
                        end
                    end
                end
            end
            return false
        end
    end,
})
zhenyi:addEffect(fk.CardUsing,{
    can_refresh = function (self, event, target, player, data)
        local mark = player:getMark("@[ym2__zhenyi]") == 0 and {value = 1,suits = {}} or player:getMark("@[ym2__zhenyi]")
        return target == player and data.card and table.contains(mark.suits,data.card:getSuitString(true))
    end,
    on_refresh = function (self, event, target, player, data)
        data.disresponsiveList = player.room.alive_players
    end,
})
zhenyi:addEffect("targetmod",{
    bypass_distances =  function(self, player, skill, card, to)
        local mark = player:getMark("@[ym2__zhenyi]") == 0 and {value = 1,suits = {}} or player:getMark("@[ym2__zhenyi]")
        return card and table.contains(mark.suits,card:getSuitString(true))
    end,
})
return zhenyi